package com.smile.viewpagecycledemo;

import android.os.Bundle;
import android.support.v4.view.ViewPager;
import android.support.v7.app.ActionBarActivity;

import com.smile.adapter.ImagePagerAdapter;
import com.smile.utils.SizeUtils;
import com.smile.widget.AutoScrollViewPager;

import java.util.Arrays;
import java.util.List;

import butterknife.ButterKnife;
import butterknife.InjectView;

public class IndexDemo extends ActionBarActivity implements ViewPager.OnPageChangeListener {

    @InjectView(R.id.ato_vpg)
    AutoScrollViewPager atoVpg;

    public final static String[] imageArryUrls = {
            "http://img.my.csdn.net/uploads/201309/01/1378037235_3453.jpg",
            "http://img.my.csdn.net/uploads/201309/01/1378037235_7476.jpg",
            "http://img.my.csdn.net/uploads/201309/01/1378037235_9280.jpg",
            "http://img.my.csdn.net/uploads/201309/01/1378037234_3539.jpg",
            "http://img.my.csdn.net/uploads/201309/01/1378037234_6318.jpg",
            "http://img.my.csdn.net/uploads/201309/01/1378037194_2965.jpg",
            "http://img.my.csdn.net/uploads/201309/01/1378037193_1687.jpg",
            "http://img.my.csdn.net/uploads/201309/01/1378037193_1286.jpg",
            "http://img.my.csdn.net/uploads/201309/01/1378037192_8379.jpg",
            "http://img.my.csdn.net/uploads/201309/01/1378037178_9374.jpg",
            "http://img.my.csdn.net/uploads/201309/01/1378037177_1254.jpg",
            "http://img.my.csdn.net/uploads/201309/01/1378037177_6203.jpg",
            "http://img.my.csdn.net/uploads/201309/01/1378037152_6352.jpg",
            "http://img.my.csdn.net/uploads/201309/01/1378037151_9565.jpg"
    };

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_index_demo);
        ButterKnife.inject(this);
        List<String> imageUrlList = Arrays.asList(imageArryUrls);
        atoVpg.setAdapter(new ImagePagerAdapter(this,imageUrlList).setInfiniteLoop(true));
        atoVpg.addOnPageChangeListener(this);
        atoVpg.setInterval(2000);
        atoVpg.startAutoScroll();
        atoVpg.setCurrentItem(Integer.MAX_VALUE / 2 - Integer.MAX_VALUE / 2 % SizeUtils.getSize(imageUrlList));
    }

    @Override
    public void onPageScrolled(int position, float positionOffset, int positionOffsetPixels) {

    }

    @Override
    public void onPageSelected(int position) {

    }

    @Override
    public void onPageScrollStateChanged(int state) {

    }
}
